Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
Datetime parse "2021-04-20T00:09:14.7724640+02:00"

Best way to parse time = "2021-04-20T00:09:14.7724640+02:00" to valid time. I need seconds as well however once

var h = DateTime.ParseExact(time.Substring(14,5), "hh:mm", CultureInfo.InvariantCulture);

this returns only hour and minute but I need seconds too, however there is 09:14.7724640+02:00 and if I tried hh:mm:ss the "." throws an "Invalid DateTimet "exception

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

string time = "2021-04-20T00:09:14.7724640+02:00";
DateTime dateTime = DateTime.Parse(time);

With this you have the whole string in the DateTime object and can do whatever you want with it (e.g. cut out hours, minutes and seconds).

over 4 years ago · Santiago Trujillo Report

0

You are looking for a timespan, datetime also contains a date part.

If you use the following code you will get a DateTime an a TimeSpan

var timeString = "2021-04-20T00:09:14.7724640+02:00";
var dateTime = DateTime.Parse(timeString);
var time = dateTime.TimeOfDay;
Console.WriteLine(time);
over 4 years ago · Santiago Trujillo Report

0

you can use ToString("dd MMMM, yyyy") and give it the format that you want

public static string GetDate(DateTime date)
        {
            return date.ToString("dd MMMM, yyyy");
        }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!